package com.example.ccj.b.c.dialogxy.impl;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.View;

import com.example.ccj.R;
import com.example.ccj.b.c.custom.image.IImageChangeDelete;
import com.example.ccj.b.c.custom.image.IImageChangeUpload;
import com.example.ccj.b.c.custom.image.ImageChangeListener;
import com.example.ccj.b.c.custom.image.LoadImagesRecycler;
import com.example.ccj.b.c.custom.image.MLocalMedia;
import com.example.ccj.b.c.custom.image.ShowBigImageChangeListener;
import com.example.ccj.b.c.custom.image.ShowBigPictureControl;
import com.example.ccj.b.c.dialogxy.IDialog;
import com.example.ccj.b.c.dialogxy.SYDialog;
import com.example.ccj.u.LogUtils;

import java.util.List;

/**
 * 大图展示dialog
 */
public class DialogTest extends SYDialog.Builder {
    ShowBigPictureControl control;
    public DialogTest(Context context) {
        super(context);
        setDialogView(R.layout.dialog_trest);
        setCancelable(true);
        setScreenHeightP(1);
        setScreenWidthP(1);
        setWindowBackground(Color.WHITE);

    }

    LoadImagesRecycler loadImagesRecycler;

    @Override
    public void initView(View layout) {
        super.initView(layout);

        loadImagesRecycler = layout.findViewById(R.id.view_add_ping_lun_img_rec);

        loadImagesRecycler.setImageChangeListener(new ImageChangeListener() {
            @Override
            public void imageNetWorkDelete(MLocalMedia images, IImageChangeDelete iImageChangeDelete) {
                ImageChangeListener.super.imageNetWorkDelete(images, iImageChangeDelete);
            }

            @Override
            public void imageLocalDelete(List<MLocalMedia> aLlImages) {
                ImageChangeListener.super.imageLocalDelete(aLlImages);
            }

            @Override
            public void imageInsert(List<MLocalMedia> nowImages) {
                ImageChangeListener.super.imageInsert(nowImages);
            }

            @Override
            public void imageInsertNetWork(List<MLocalMedia> nowImages, IImageChangeUpload iImageChangeUpload) {
                ImageChangeListener.super.imageInsertNetWork(nowImages, iImageChangeUpload);
                iImageChangeUpload.onUpload(nowImages);
            }
        });

        loadImagesRecycler.show();
    }

    List<MLocalMedia> imageList;

    public DialogTest setData(List<MLocalMedia> imageList){
        this.imageList = imageList;
        return this;
    }

    int showMode;
    public DialogTest setImageChangeListener(int showMode){
        this.showMode = showMode;
        return this;
    }

    ShowBigImageChangeListener imageChangeListener;

    public DialogTest setImageChangeListener(ShowBigImageChangeListener imageChangeListener){
        this.imageChangeListener = imageChangeListener;
        setOnDismissListener(new IDialog.OnDismissListener() {
            @Override
            public void onDismiss(IDialog dialog) {
                imageChangeListener.over(control);
            }
        });
        return this;
    }





    @Override
    public SYDialog show() {
        return super.show();
    }
}
